﻿namespace ErikLieben.CssPreprocessor.Tests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class CleanupTests
    {

        [TestMethod]
        public void Cleanup_CleanUpCss_should_remove_spaces_before_bracket()
        {
            // Arrange
            string input = ".main {";

            // Act
            string result = Cleanup.CleanUpCss(input);

            // Assert
            Assert.AreEqual(".main{", result);
        }

        [TestMethod]
        public void Cleanup_CleanUpCss_should_remove_spaces_after_bracket()
        {
            // Arrange
            string input = ".main{ ";

            // Act
            string result = Cleanup.CleanUpCss(input);

            // Assert
            Assert.AreEqual(".main{", result);
        }

        [TestMethod]
        public void Cleanup_CleanUpCss_should_remove_spaces_before_colon()
        {
            // Arrange
            string input = "background-color :";

            // Act
            string result = Cleanup.CleanUpCss(input);

            // Assert
            Assert.AreEqual("background-color:", result);
        }

        [TestMethod]
        public void Cleanup_CleanUpCss_should_remove_spaces_after_colon()
        {
            // Arrange
            string input = "background-color: ";

            // Act
            string result = Cleanup.CleanUpCss(input);

            // Assert
            Assert.AreEqual("background-color:", result);
        }

        [TestMethod]
        public void Cleanup_CleanUpCss_should_remove_spaces_after_comma()
        {
            // Arrange
            string input = ".note, .main";

            // Act
            string result = Cleanup.CleanUpCss(input);

            // Assert
            Assert.AreEqual(".note,.main", result);
        }

        [TestMethod]
        public void Cleanup_CleanUpCss_should_remove_spaces_after_semicolon()
        {
            // Arrange
            string input = "blue;";

            // Act
            string result = Cleanup.CleanUpCss(input);

            // Assert
            Assert.AreEqual("blue;", result);
        }

        [TestMethod]
        public void Cleanup_CleanUpCss_should_remove_semicolon_before_bracket()
        {
            // Arrange
            string input = "blue;}";

            // Act
            string result = Cleanup.CleanUpCss(input);

            // Assert
            Assert.AreEqual("blue}", result);
        }

        [TestMethod]
        public void Cleanup_CleanUpCss_should_remove_double_spaces()
        {
            // Arrange
            string stringWithDoubleSpaces = "should be     with                    out any doub  /*take*/        le spaces";

            // Act
            string result = Cleanup.CleanUpCss(stringWithDoubleSpaces);

            // Assert
            Assert.AreEqual("should be without any double spaces", result);
        }

        [TestMethod]
        public void Cleanup_CleanUpCss_should_not_contain_comments()
        {
            // Arrange
            string stringWithComments = "The image below shows a user /* in which allows */users /*take*/  part";

            // Act
            string result = Cleanup.CleanUpCss(stringWithComments);

            // Assert
            Assert.AreEqual("The image below shows a user users part", result);
        }

        [TestMethod]
        public void Cleanup_RemoveVariableTags_should_remove_variable_tags()
        {
            // Arrange
            string input = "foo@variable { background : red;foreground:green}boo";

            // Act
            string result = Cleanup.RemoveVariableTags(input);

            // Assert
            Assert.AreEqual("fooboo", result);
        }
    }
}
